Repository navigation
fix(agent-session): send prompts to sessions with no on-disk transcript yet - #183
Conversation
…pt yet A session whose prompts were all local slash commands never started an agent run, so omp writes no session file. snapshotRunEntries threw on the 404 from the boundary read, which sits before prompt dispatch, so the send failed with 'HTTP 404' and follow-up messages were dropped. Treat that 404 as an empty baseline, the same way loadSession already tolerates the missing file. Add a regression test.
|
Thanks for the report — this is a good catch on a real failure mode, and the fix itself is exactly the right shape. Two notes before I merge, one of which is about the description rather than the code. What I verifiedI re-derived your repro against today's That is not a reason to close this, because it still closes a narrower hole that really is live: when the session file exists but cannot be read or resolved, that route returns I also confirmed the things that usually break in this file: Two things worth knowingThe comment overclaims. "There is no prior run to diff against" is not true for every The regression test models a state the server cannot produce. It stubs the boundary fetch as Merging the code as it stands. |
kahme247
left a comment
There was a problem hiding this comment.
The client-side 404 -> empty-baseline fallback closes a real hole that merged #165 does not cover (session file exists but is unreadable -> session_file_malformed). Fencing intact, real failures still surface. Details in my comment above.
Merged #183 turns a 404 from the boundary read into an empty baseline so a prompt is still dispatched. Its own regression test stubs a state the server cannot produce -- the harness's /api/agent stub succeeds for any unknown id, which the real route never does -- so it does not actually pin the fix. These three do: - the fileless live session that merged #165 already answers 200, proven on the unfixed source, so the original repro no longer exists; - a 404 boundary on a live session (unreadable file, or a wrapper that died between get_state and the read) still dispatches, which is the case #183 genuinely closes; - a vanished session with no wrapper still fails loudly, so the new fallback did not swallow a real error.
Merged #183 turns a 404 from the boundary read into an empty baseline so a prompt is still dispatched. Its own regression test stubs a state the server cannot produce -- the harness's /api/agent stub succeeds for any unknown id, which the real route never does -- so it does not actually pin the fix. These three do: - the fileless live session that merged #165 already answers 200, proven on the unfixed source, so the original repro no longer exists; - a 404 boundary on a live session (unreadable file, or a wrapper that died between get_state and the read) still dispatches, which is the case #183 genuinely closes; - a vanished session with no wrapper still fails loudly, so the new fallback did not swallow a real error.
Summary
A session whose prompts were all local slash commands, such as
/skill:poteto-mode, never starts an agent run, so omp writes no session file. Any later send read the transcript boundary from disk, got a 404, and threw before the prompt was dispatched. You sawFailed to send message: HTTP 404, the session looked dead, and follow-up messages were dropped.Changes
snapshotRunEntriesnow treats that 404 as an empty baseline and lets the send proceed.loadSessionin the same file already tolerates the missing file the same way, so this brings the boundary read in line with it.Test
New regression case in
useAgentSession.rpc.test.mjs: a session that answers/api/agent/<id>but has no session file still dispatches the prompt, with no error notice. Full suite passes (99 tests).